<template>
  <div class="app-container">
    <el-button
      type="primary"
      @click="handleAdd"
      >新增</el-button
    >
    <el-dialog
      title="新增"
      :visible.sync="dialogVisible"
      width="30%"
      >
      <el-form ref="form" :model="form">
        <el-form-item label="" prop="classString" :rules="[
            { required: true, message: '请输入内容', trigger: 'blur' },
          ]">
          <el-input
            type="textarea"
            placeholder="请输入内容"
            v-model="form.classString"
            :autosize="{ minRows: 10}"
          >
          </el-input>
        </el-form-item>
      </el-form>

      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleSure">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { defaultClassGenerateCom } from '@/api/codeManagement'
export default {
  data() {
    return {
      dialogVisible:false,
      form:{
        classString:""
      }
    }
  },
  methods:{
    handleAdd(){
      this.dialogVisible=true
      this.form.classString=""
    },
    handleSure(){
      this.$refs["form"].validate(async (valid) => {
        if (valid) {
          const res = await defaultClassGenerateCom(this.form);
          if (res?.code === 200) {
            this.dialogVisible=false
            this.$message({
              message: "保存成功",
              type: "success",
            });
          }
        }
      })
    }
  }
}
</script>

